public class demo2 {
    /**
     * 继承 Thread, 重写 run
     * 实现 Runnable, 重写 run
     * 继承 Thread, 重写 run, 使用匿名内部类
     * 实现 Runnable, 重写 run, 使用匿名内部类
     * 使用 lambda 表达式
     */
    public static void main(String[] args) throws InterruptedException {
        class Mythread extends Thread{
            @Override
            public void run() {
                System.out.println("Thread extending Thread is runing");
            }
        }

        class  MyRunnable implements Runnable {
            @Override
            public void run() {
                System.out.println("Thread  implementing Runnable is running");
            }
        }

        Thread thread1 = new Thread(){
            @Override
            public void run() {
                System.out.println("Thread extending Thread with anonymous inner class is runing");
            }
        };
        Runnable runnable = new Runnable(){
            @Override
            public void run() {
                System.out.println("Thread  implementing Runnable with anonymous inner class is running");
            }
        };
        Thread thread2 = new Thread(() ->{
            System.out.println("Thread using lambda expression is running");
        });
        Mythread mythread =new  Mythread();
        mythread.run();


        MyRunnable myRunnable = new MyRunnable();
        myRunnable.run();

        Thread thread = new Thread(myRunnable);
        thread.start();

        thread1.start();
        thread2.start();

        thread1.join();
        thread2.join();





    }
}
